#include "strlib.h"

void trim(char* str, char* newstr){	
	if (str == NULL) return;
	int j = strlen(str) -1;
	while (isspace(str[j])) {
		j--;
	}
	int k = 0;
	while (isspace(str[k]) && k < j) {
		k++;
	}
	int i, h = 0;
	for (i = k; i <= j; i++){
		newstr[h++] = str[i];	
	}
	newstr[h] = '\0';
}


void strreplace(char* str, char haystack, char needle){
	if (str == NULL || strlen(str) == 0) return;
	int i = 0;
	int len = strlen(str);
	for (i = 0; i < len; i++){
		if (str[i] == haystack)
			str[i] = needle;	
	}
}


int isNumeric(char* str){
	if (str == NULL || strlen(str) == 0) return 0;
	int i;
	for (i = 0; str[i] != '\0'; i++){
		if (!isdigit(str[i])) return 0;
	}
	return 1;
}
